package lab3p1;

/**
 * <p>Title: GameDay</p>
 * <p>Description: CS 235 Lab #3</p>
 *         A simple Java graphical user interface program
 *         that keeps track of the date of a game.
 * @author Anthony Varghese
 * @date   August 8th 2013
 * @team   
 */

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class GameDay extends JFrame implements ActionListener {
	/**
	 * Default serial version id so we don't get compiler warnings.
	 */
	private static final long serialVersionUID = 1L;

	private JLabel     description;
	private final String DESCR_STRING = "The game is at";
	private JTextField hours;
	private JLabel     colon;
	private final String COLON_STRING = ":";
	private JTextField minutes;
	private JLabel     ampm;
	private String AMPM_STRING = "AM";

	private JLabel on;
	private final String ON_STRING = "on";
	private JTextField day;
	private JTextField month;
	private JTextField year;
	private JLabel     yearprefix;
	private final String YEAR_PREFIX_STRING = "20";
	private final Font biggerFont = new Font("SansSerif", Font.BOLD, 16 );
	
	private JButton check;

	/**
	 * Constructor
	 * 
	 * @param title
	 */
	public GameDay(String title) {
		super(title);
		
		setBounds( 200, 100, 400, 300 );
		setLayout( null );

		description = new JLabel( DESCR_STRING );
		description.setBounds( 70, 10, 150, 30 );
		description.setFont( biggerFont );
		add( description );

		hours = new JTextField( );
		hours.setBounds( 200, 10, 40, 30 );
		add( hours );

		colon = new JLabel( COLON_STRING );
		colon.setBounds( 245, 10, 150, 30 );
		colon.setFont( biggerFont );
		add( colon );

		minutes = new JTextField( );
		minutes.setBounds( 250, 10, 40, 30 );
		add( minutes );

		ampm = new JLabel( AMPM_STRING );
		ampm.setBounds( 300, 10, 150, 30 );
		add( ampm );

		on = new JLabel( ON_STRING );
		on.setBounds( 170, 60, 150, 30 );
		add( on );

		day = new JTextField( );
		day.setBounds( 250, 60, 40, 30 );
		add( day );

		month = new JTextField( );
		month.setBounds( 200, 60, 40, 30 );
		add( month );

		yearprefix = new JLabel( YEAR_PREFIX_STRING );
		yearprefix.setBounds( 300, 60, 150, 30 );
		yearprefix.setFont( biggerFont );
		add( yearprefix );

		year = new JTextField( );
		year.setBounds( 330, 60, 40, 30 );
		year.setFont( biggerFont );
		add( year );

		check = new JButton("Check");
		check.setBounds( 70, 200, 90, 40);
		add( check );
		check.addActionListener( this );
		
		setDefaultCloseOperation( EXIT_ON_CLOSE );
		setVisible( true );
	}

	/**
	 * actionPerformed
	 * - gets the data in all the fields in response to a button click
	 */
	public void actionPerformed(ActionEvent e) {
		System.out.println("------- Data from window: ----");
		System.out.println(" minute: " + minutes.getText() );
		System.out.println(" hour:   " + hours.getText()   );
		System.out.println(" day:    " + day.getText() );
		System.out.println(" month:  " + month.getText()   );
		System.out.println(" year:   " + year.getText()   );
	}

	/**
	 * main 
	 * @param args
	 */
	public static void main(String[] args) {
		new GameDay( "Playoff Game" );
	}
}
